import request from '@/utils/request'

// 查询网关列表
export function listGateway(query) {
  return request({
    url: '/system/gateway/list',
    method: 'get',
    params: query
  })
}

// 查询网关详细
export function getGateway(id) {
  return request({
    url: '/system/gateway/' + id,
    method: 'get'
  })
}

// 查询网关详细
export function getGatewayByIdOrMac(query) {
  return request({
    url: '/system/gateway/',
    method: 'get',
    params: query
  })
}

// 新增网关
export function addGateway(data) {
  return request({
    url: '/system/gateway',
    method: 'post',
    data: data
  })
}

// 修改网关
export function updateGateway(data) {
  return request({
    url: '/system/gateway',
    method: 'put',
    data: data
  })
}

// 删除网关
export function delGateway(id) {
  return request({
    url: '/system/gateway/' + id,
    method: 'delete'
  })
}

// 解绑网关
export function Untiegateway(id) {
  return request({
    url: '/system/gateway/untie/' + id,
    method: 'put'
  })
}

// 导出网关
export function exportGeteway(query) {
  return request({
    url: '/system/gateway/export',
    method: 'get',
    params: query
  })
}

// 查询家庭下的网关列表(目前一个家庭下只有一个网关, 所以只需访问数组第一个元素即可)
export function getGatewayListByHomeId(query) {
  return request({
    url: '/system/gateway/listByHomeId',
    method: 'get',
    params: query
  })
}

export function sendCmd(query) {
  return request({
    url: '/system/gateway/send/cmd',
    method: 'get',
    params: query
  })
}
